/*
 * Copyright 2013 tsp. All rights reserved.
 */


import java.awt.Component;

import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

/** 
 * 
 */
public class JCheckBoxRenderer extends JCheckBox implements TableCellRenderer {

	public JCheckBoxRenderer() {
		this.setHorizontalAlignment(JLabel.CENTER); 
	}

	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {
		if (isSelected) {
			setForeground(table.getSelectionForeground());
			setBackground(table.getSelectionBackground());
		} else {
			setForeground(table.getForeground());
			setBackground(table.getBackground());
		}
		if (value == null || !(value instanceof Boolean)) {
			value = new Boolean(false);
		}
		setSelected(((Boolean) value).booleanValue());
		return this;
	}
}
